﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Biza.Core.Extentions
{
    /// <summary>
    /// String类型扩展
    /// </summary>
    public static class StringExtention
    {
        /// <summary>
        /// 判断字符串是否存在于一个字符串数组中
        /// </summary>
        /// <param name="s">源字符串</param>
        /// <param name="arrStr">目标字符串数组</param>
        /// <returns>是否存在</returns>
        public static bool IsIn(this string s, params string[] arrStr)
        {
            if (arrStr == null) return false;
            return arrStr.FirstOrDefault(x => x.Equals(s)) != null;
        }

        /// <summary>
        /// 将字符串从右边截短为指定的长度
        /// </summary>
        /// <param name="s">源字符串</param>
        /// <param name="length">目标长度</param>
        /// <returns>截短后的字符串</returns>
        public static string CutRight(this string s, int length)
        {
            return s.Substring(s.Length - length, length);
        }

    }
}
